﻿namespace Blaze.Editor.UI
{
    using Framework;
    using UnityEditor;

    [CustomEditor(typeof (AnimationCurveAsset), true)]
    public class AnimationCurveAssetInspector : Editor
    {
        /// <summary>
        /// <para>
        /// Implement this function to make a custom inspector.
        /// </para>
        /// </summary>
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            var asset = (AnimationCurveAsset) target;
            var curve = asset.curve;
            mIsFoldout = EditorGUILayout.Foldout(mIsFoldout, "Keyframes Data");
            if (mIsFoldout)
            {
                for (int index = 0; index < curve.keys.Length; index++)
                {
                    var keyframe = curve.keys[index];
                    EditorGUILayout.TextField(index.ToString(), string.Format("{0},{1},{2},{3}", keyframe.time, keyframe.value, keyframe.inTangent, keyframe.outTangent));
                }
            }
        }

        private bool mIsFoldout;
    }
}